package org.bizbundles.translate;

import javax.swing.*;
import java.util.List;
import java.awt.*;

/**
 * Copyright 2007 BizBundle.org
 * <p/>
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * <p/>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p/>
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 * @author Steve Roach
 * @since: Nov 14, 2007
 * 9:28:06 PM
 */
class TableOutput extends JPanel
{


    public TableOutput(String[] columns, List<TableData> tableData)
    {
        super(new GridLayout(1, 0));

        JTable table = new ITunesTable(new ResourceTable(tableData, columns));
        table.setPreferredScrollableViewportSize(new Dimension(500, 70));
        //table.setFillsViewportHeight(true);

        //Create the scroll pane and add the table to it.
        JScrollPane scrollPane = new JScrollPane(table);

        //Add the scroll pane to this panel.
        add(scrollPane);
    }


    /**
     * Create the GUI and show it.  For thread safety,
     * this method should be invoked from the
     * event-dispatching thread.
     *
     * @param columns   col
     * @param tableData dt
     */
    protected void createAndShowGUI(String[] columns, List<TableData> tableData)
    {
        //Create and set up the window.
        JFrame frame = new JFrame("Tabular Output");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        //Create and set up the content pane.
        TableOutput newContentPane = new TableOutput(columns, tableData);
        newContentPane.setOpaque(true); //content panes must be opaque
        frame.setContentPane(newContentPane);

        //Display the window.
        frame.pack();
        frame.setVisible(true);
    }

    /*     public static void main(String[] args) {
        //Schedule a job for the event-dispatching thread:
        //creating and showing this application's GUI.
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    }*/
}
